<template>
  <div class="contentView" v-loading="formLoading">
    <div class="routeHeader">
      <el-button @click="submitForm" type="primary" :disabled="formLoading">保 存</el-button>
      <el-button @click="goBack">关 闭</el-button>
    </div>
    <ContentWrap>
      <Table :columns="tableTitleList" :selection="false" :data="tableList">
        <template #deviceCode="{ row }">
        {{ row.deviceCode }}123
      </template>
      </Table>
    </ContentWrap>

    <!-- <el-table ref="tableRef" :data="tableList" style="width: 100%" border class="tableView">
      <el-table-column type="index" width="80" label="序号" align="center" />
      <el-table-column
        :property="item.val"
        :label="item.label"
        :min-width="item.width"
        :key="item.val"
        v-for="item in tableTitleList"
        align="center"
      >
        <template #default="scope">
          <template
            v-if="['proportion', 'explaind', 'ratedOperatingTime'].includes(item.val)"
          >
            <el-input
              v-model="scope.row[item.val]"
              :disabled="
                formType ||
                (item.val == 'proportion' && ![2, 3].includes(formData.dictStatus))
              "
              :type="['ratedOperatingTime', 'proportion'].includes(item.val) ? 'number' : 'text'"
            />
          </template>
          <template v-else-if="item.val === 'componentProductId'">
            <el-select
              v-model="scope.row[item.val]"
              class="!w-120px"
              :disabled="formType || ![2, 3].includes(formData.dictStatus)"
            >
              <el-option
                v-for="dict in productDetailList"
                :key="dict.id"
                :label="dict.componentName"
                :value="dict.id"
              />
            </el-select>
          </template>
          <template v-else-if="['jobNumber'].includes(item.val)">
            <el-select
              v-model="scope.row[item.val]"
              filterable
              remote
              reserve-keyword
              :remote-method="
                (e) => {
                  getSelectDesignersList(e, scope.$index)
                }
              "
              :loading="designersLoading"
              class="!w-120px"
              :disabled="formType"
            >
              <el-option
                v-for="dict in scope.row.designersList"
                :key="dict.jobNumber"
                :label="dict.designerPersonName"
                :value="dict.jobNumber"
              />
            </el-select>
          </template>
          <template v-else-if="item.val == 'operation'">
            <el-button
              @click="delComponent(scope.$index)"
              type="danger"
              :disabled="formType || ![2, 3].includes(formData.dictStatus)"
              >移除行</el-button
            >
          </template>
          <template v-else>
            <el-date-picker
              style="width: 180px"
              v-model="scope.row[item.val]"
              type="date"
              value-format="YYYY-MM-DD"
              :placeholder="`选择${item.label}`"
              :disabled="formType"
            />
          </template>
        </template>
      </el-table-column>
    </el-table> -->
  </div>
</template>
<script setup lang="ts">
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { useTagsViewStore } from '@/store/modules/tagsView'
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗

/** 提交表单 */
const submitForm = async () => {
  message.success(t('common.updateSuccess'))
}

/**返回 */
const tagsViewStore = useTagsViewStore()
const route = useRouter() // 路由
const goBack = async () => {
  //获取当前路由并删除tagView
  tagsViewStore.delView(route.currentRoute.value)
  //跳转列表页
  route.push({
    path: '/produce/produce/workOrderManagement/productionTaskTeamsOrder'
  })
}

/** 初始化 */
//const { params } = useRoute() // 路由的查询
const tableList = ref([]) //表格数据
let tableTitleList = reactive<CrudSchema[]>([]) // 表头的数据
onMounted(async () => {
  let dataList = JSON.parse(history.state.tableTitleList)
  dataList.pop()
  tableTitleList = dataList
  tableList.value = JSON.parse(history.state.tableList)
  console.log(dataList)
})
</script>
